Skip to content

Fix missing last opened result due to race condition from plugins that call hide directly#4408

Merged
jjw24 merged 1 commit intodevfrom
fix_lasthistory_sysplugin
Apr 11, 2026
Merged

Fix missing last opened result due to race condition from plugins that call hide directly#4408
jjw24 merged 1 commit intodevfrom
fix_lasthistory_sysplugin

Conversation

@jjw24
Copy link
Copy Markdown
Member

@jjw24 jjw24 commented Apr 11, 2026

Follow on from #4375 with issue #4374

Problem:
Some Sys plugin results (e.g 'Settings') do not show up in 'Empty Last Query' query style mode after they are selected, and would only show when re-queried or clearing of a new query.

Cause:
When plugin actions call Context.API.HideMainWindow() directly it does a re-query before the result is added to last history items and consequently the second Hide() call at the end of OpenResultAsync(string) would not trigger a re-query because QueryText is already "", so QueryText != queryText is false. Without a re-query the newly added last history item does not get added to result list display.

Fix:
Move _history.Add(result) to immediately after the result == null check, before ExecuteAsync(ActionContext) is called, guaranteeing that history is updated before any possible Hide() invocation — whether triggered from inside the plugin action or from the explicit Hide() call afterward.

Tested:

  • Results like 'Settings' from Sys plugin show up after selection

Summary by cubic

Fixes a race that caused the last selected system plugin result (e.g., “Settings”) to not appear in “Empty Last Query” mode. We now record the history entry before executing the action, so plugin-triggered re-queries don’t drop it.

  • Summary of changes
    • Changed: In OpenResultAsync, add the selected result to history before ExecuteAsync and any Hide() call; applies only to query results (not context menu/history).
    • Added: Set lastHistoryIndex = 1 at the time of the early history write to ensure correct positioning in history.
    • Removed: The late _history.Add block after ExecuteAsync, avoiding missed updates and duplicate logic.
    • Memory usage: No impact; same history size and allocations, only call order changed.
    • Security: No new risks; internal ordering change only, no new I/O or permissions.
    • Tests: No new unit tests; manually verified that Sys plugin entries like “Settings” now appear immediately in “Empty Last Query” mode.

Written for commit a250e79. Summary will update on new commits.

@prlabeler prlabeler bot added the bug Something isn't working label Apr 11, 2026
@github-actions github-actions bot added this to the 2.2.0 milestone Apr 11, 2026
@jjw24 jjw24 added Dev branch only An issue or fix for the Dev branch build and removed bug Something isn't working labels Apr 11, 2026
@prlabeler prlabeler bot added the bug Something isn't working label Apr 11, 2026
@coderabbitai coderabbitai bot removed the bug Something isn't working label Apr 11, 2026
@gitstream-cm
Copy link
Copy Markdown

gitstream-cm bot commented Apr 11, 2026

🥷 Code experts: Jack251970

Jack251970 has most 👩‍💻 activity in the files.
Jack251970 has most 🧠 knowledge in the files.

See details

Flow.Launcher/ViewModel/MainViewModel.cs

Activity based on git-commit:

Jack251970
APR 3 additions & 3 deletions
MAR
FEB 11 additions & 6 deletions
JAN 50 additions & 35 deletions
DEC
NOV 106 additions & 94 deletions

Knowledge based on git-blame:
Jack251970: 94%

✨ Comment /gs review for LinearB AI review. Learn how to automate it here.

@gitstream-cm
Copy link
Copy Markdown

gitstream-cm bot commented Apr 11, 2026

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6aeae0c6-0f1b-4a16-a241-b9a7b8069779

📥 Commits

Reviewing files that changed from the base of the PR and between f5097c2 and a250e79.

📒 Files selected for processing (1)
  • Flow.Launcher/ViewModel/MainViewModel.cs

📝 Walkthrough

Walkthrough

A reordering of history-recording logic in MainViewModel.OpenResultAsync to execute immediately after result validation and before window hiding or result execution, rather than after execution.

Changes

Cohort / File(s) Summary
History Recording Reorder
Flow.Launcher/ViewModel/MainViewModel.cs
Moved history-recording block earlier in OpenResultAsync execution flow—now executes after result validation but before hideWindow determination and ExecuteAsync invocation. Removed the previous post-execution history-recording block.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • Jack251970
  • taooceros
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly describes the main fix: addressing a race condition where plugins calling hide directly caused missing last opened results.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the problem, root cause, solution, and testing performed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix_lasthistory_sysplugin

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jjw24 jjw24 enabled auto-merge (squash) April 11, 2026 10:12
@jjw24 jjw24 merged commit 87fb7ae into dev Apr 11, 2026
16 checks passed
@jjw24 jjw24 deleted the fix_lasthistory_sysplugin branch April 11, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dev branch only An issue or fix for the Dev branch build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants